// 引入axios
import axios from 'axios'

// 配置基准路径
axios.defaults.baseURL = 'http://localhost:8888/api'

// 路由配置
/* 获取新闻资讯列表 */
export const getnewslist = () => axios.get('/getnewslist').then(res => { return res.data })

/* 获取新闻详情 */
export const getNewsDetail = (id) => axios.get(`/getnew/${id}`).then(res => { return res.data })

/* 获取评论列表 */
export const getComments = (id, pageindex) => axios.get(`/getcomments/${id}`, { params: { pageindex } }).then(res => { return res.data })

/* 发表评论 */
export const publicComment = (id, content) => axios.post(`/postcomment/${id}`, content).then(res => { return res.data })

/* 获取图片列表顶部分类 */
export const getImgCategory = () => axios.get('/getimgcategory').then(res => { return res.data })

/* 根据分类id获取图片列表 */
export const getImgList = (id) => axios.get(`/getimages/${id}`).then(res => { return res.data })

/* 图文详情缩略图 及 商品列表详情轮播图 */
export const getThumImg = (id) => axios.get(`/getthumimages/${id}`).then(res => { return res.data })

/* 获取缩略图描述 */
export const getThumDesc = (id) => axios.get(`/getimageInfo/${id}`).then(res => { return res.data })

/* 获取商品列表 */
export const getGoodsList = (pageindex) => axios.get('/getgoods', { params: { pageindex } }).then(res => { return res.data })

/* 获取商品价格及描述 */
export const getGoodsDesc = (id) => axios.get(`/goods/getinfo/${id}`).then(res => { return res.data })

/* 获取商品图文介绍 */
export const getGoodsInfo = (id) => axios.get(`/goods/getdesc/${id}`).then(res => { return res.data })

/* 获取购物车页面数据 */
export const getCartsInfo = (id) => axios.get(`/goods/getshopcarlist/${id}`).then(res => { return res.data })
